require "Common/define"
require "Logic/Config"
require "Common/functions"
---@class RedDotsTaskTimeBoxKeyEnoughHandler
RedDotsTaskTimeBoxKeyEnoughHandler ={};
local this = RedDotsTaskTimeBoxKeyEnoughHandler;

function RedDotsTaskTimeBoxKeyEnoughHandler.init()

    CloseEvent(Config.EventType.RedDotsTimeBoxKeyEnough,this.update);
    CloseEvent(Config.EventType.Fresh_Bag,this.update);
    ListenEvent(Config.EventType.RedDotsTimeBoxKeyEnough,this.update);
    ListenEvent(Config.EventType.Fresh_Bag,this.update);
    return this;
end

-- 参数1： 任务类型。
function RedDotsTaskTimeBoxKeyEnoughHandler.getFlag(...)
    if logicMgr.FuncOpenManager.isOpen(Config.FuncOpenType.TimeBoxAll,false) then
        local param = {...}
        if #param ~= 1 then return  Config.RedDotsFlagState.None end
        if TimeBoxHandler.KeyEnoughOpen(param[1]) then
            return Config.RedDotsFlagState.Needful
        end
    end
    return Config.RedDotsFlagState.None;
end


function RedDotsTaskTimeBoxKeyEnoughHandler.update()
    RedDotsManager.addBroadcast(Config.RedDotsType.TaskTimeBoxKeyEnough);
end